package com.water.controller;

import com.water.entity.UsUser;
import com.water.service.UsUserService;
import org.springframework.web.bind.annotation.*;
import org.springframework.ui.Model;

import javax.annotation.Resource;
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;

/**
 * (UsUser)表控制层
 *
 * @author makejava
 * @since 2020-12-14 19:19:07
 */
@RestController
@RequestMapping("usUser")
public class UsUserController {
    /**
     * 服务对象
     */
    @Resource
    private UsUserService usUserService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public UsUser selectOne(String id) {
        return this.usUserService.queryById(id);
    }

    @PostMapping("getuser")
    public Map<String,Object> getuser(@RequestParam("olduserno") String olduserno){
        Map<String, Object> maps = usUserService.queryByno(olduserno);
        if (maps != null) {//判断对象存不存在
            UsUser usUser = usUserService.queryById(olduserno);//查询对象所有数据
            Object disabled=usUser.getDisabled();//得到禁用启用状态（0启用，1禁用）
            if (disabled.equals(1)) {
                Object disabled1 = usUser.getDisabled();
                System.out.println(disabled1);
                maps.put("disabled",disabled1);//向map加入状态数据（0/1）
            }
        }
        return maps;
    }


    @PostMapping("getlookuser")
    public Map<String,Object> getfenhuuser(@RequestParam("olduserno") String olduserno){
        Map<String, Object> map = usUserService.queryByno(olduserno);
        if (map != null) {//判断对象存不存在
            UsUser usUser = usUserService.queryById(olduserno);//查询对象所有数据
            Object disabled=usUser.getDisabled();//得到禁用启用状态（0启用，1禁用）
            if (disabled.equals(1)) {
                Object disabled1 = usUser.getDisabled();
                map.put("disabled",disabled1);//向map加入状态数据（0/1）
            }
        }
        return map;
    }


}